package two.dimensional.arrays;

import java.util.Arrays;

/**
 * @author shkstart
 * @date 2022/4/18 - 22:15
 */
public class ArraysTest {
    public static void main(String[] args) {
        //1.boolean equals(int[] a,int[] b):判断两个数组是否相等。
        int arr[] = {1,2,3,4};
        int arr1[] = {1,3,2,4};
        boolean isEquals = Arrays.equals(arr,arr1);
        System.out.println(isEquals);

        //2.String toString(int[] a):输出数组信息。

        System.out.println(Arrays.toString(arr));

        //3.void fill(int[] a,int val):将指定值填充到数组之中。
        Arrays.fill(arr,20);
        System.out.println(Arrays.toString(arr));


        //4.void sort(int[] a):对数组进行排序。
        Arrays.sort(arr1);
        System.out.println(Arrays.toString(arr1));

        //5.int binarySearch(int[] a,int key)
        int[] arr3 = new int[]{-98,-34,2,34,54,66,79,105,210,333};
        int index = Arrays.binarySearch(arr3,333);
        if (index >= 0) {
            System.out.println(index);
        }else {
            System.out.println("未找到");
        }
    }
}
